﻿Imports System.Data.SqlClient

Public Class Lop


    Private Sub label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles label1.Click
       
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDS.Click
        Dim con As New SqlConnection()
        con.ConnectionString = Ketnoi.str
        con.Open()
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        Dim TenLop As String
        TenLop = cboDSLop.SelectedItem.ToString()
        cmd.CommandText = "SELECT MaLop FROM Lop WHERE TenLop='" + TenLop + "'"
        Dim rd As SqlDataReader
        rd = cmd.ExecuteReader()
        Dim td As New DataTable()
        td.Load(rd)
        Dim MaLop As String
        MaLop = td.Rows(0)(0).ToString()
        con.Close()
        Dim frmDS As New DanhSachSinhVien(MaLop)
        frmDS.Show()
        Me.Close()
    End Sub

    Private Sub Lop_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim con As New SqlConnection()
        con.ConnectionString = Ketnoi.str
        con.Open()
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        cmd.CommandText = "SELECT * FROM LOP"
        Dim rd As SqlDataReader
        rd = cmd.ExecuteReader()
        Dim td As New DataTable()
        td.Load(rd)
        Dim i As Integer = 0
        While i < td.Rows.Count
            Me.cboDSLop.Items.Add(td.Rows(i)(1))
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
        End While
        con.Close()
    End Sub

    Private Sub cboDSLop_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDSLop.SelectedIndexChanged

    End Sub
End Class